"""
基础时间线柱状图

- 创建时间线
"""

from pyecharts.charts import Bar, Timeline
from pyecharts.options import LabelOpts

# 构建柱状图对象
bar1 = Bar()
bar2 = Bar()

# x轴
bar1.add_xaxis(["中国", "美国", "英国"])
bar2.add_xaxis(["中国", "美国", "英国"])

# y轴
bar1.add_yaxis("GDP", [30, 20, 10], label_opts=LabelOpts(position="right"))
bar2.add_yaxis("GDP", [60, 40, 50], label_opts=LabelOpts(position="right"))

# 反转 x 轴
bar1.reversal_axis()
bar2.reversal_axis()

# 构建时间线
time_line = Timeline()
time_line.add(bar1, "2021GDP")
time_line.add(bar2, "2022GDP")

time_line.render("基础柱状图-时间线.html")
